﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using EQ1.Elements;
using EQ1.Objects;

namespace EQ1.Templates {
  public class SpellGemDrawTemplate : UIClass, IUIElement<SpellGemDrawTemplate> {
    public SpellGemDrawTemplate ( UIDocument doc , string name )
      : base( doc , name ) {
    }
    public SpellGemDrawTemplate ( UIDocument doc )
      : this( doc , "SpellGemDrawTemplate" ) {
    }

    #region IUIElement<SpellGemDrawTemplate> Members

    public void Validate ( SpellGemDrawTemplate val , string name ) {
      UIClass par = ( UIClass ) this.ParentNode;

      if( val.LocalName != name ) {
        SpellGemDrawTemplate el = new SpellGemDrawTemplate( ( UIDocument ) val.OwnerDocument , name );
        el.Copy( val );
        val = el;
      }

      if( par.GetElement( name ) != null )
        par.RemoveElement( name );

      par.AppendChild( val );
    }
    public void Copy ( SpellGemDrawTemplate val ) {
      base.Copy( val );

      if( string.IsNullOrEmpty( val.Holder ) )
        this.Holder = val.Holder;
      if( string.IsNullOrEmpty( val.Background ) )
        this.Background = val.Background;
      if( string.IsNullOrEmpty( val.Highlight ) )
        this.Highlight = val.Highlight;
    }

    #endregion
    
    public string Holder {
      get {
        return this.GetElement( "Holder" ).InnerText;
      }
      set {
        this.Validate( "Holder" , value );
      }
    }
    public string Background {
      get {
        return this.GetElement( "Background" ).InnerText;
      }
      set {
        this.Validate( "Background" , value );
      }
    }
    public string Highlight {
      get {
        return this.GetElement( "Highlight" ).InnerText;
      }
      set {
        this.Validate( "Highlight" , value );
      }
    }

  }
}
